package com.threadTest.testDemo01;


import javax.print.ServiceUIFactory;

/**
 * @Author weijingchen
 * @Date 2025/6/23 9:50
 * @Version 1.0.0
 */
public class Wind extends Thread {
    /**
     * 窗口买票
     */
    public static int ticket = 100;
    @Override
    public void run() {
        while (true) {
            synchronized (Wind.class) {
                if (ticket <= 10){
                    System.out.println("票已卖完");
                    break;
                }else {
                    System.out.println(getName() + "正在卖第" + ticket + "张票");
                    ticket--;
                    System.out.println("剩余票数：" + ticket);
                    try {
                        Wind.class.wait(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    Wind.class.notifyAll();
                }

            }
        }
    }
}
